Fix pointer encoding in vncfb (middle and right button were swapped).
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 15 Dec 2006 17:30:51 +0000 (17:30 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 15 Dec 2006 17:30:51 +0000 (17:30 +0000)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
tools/xenfb/vncfb.c

index 49fc7306257468236dfb5d0e65098f216726b497..7bb834ee2b5acbad7c68c426f817ae4f2b7ca79b 100644 (file)
@@ -148,6 +148,10 @@ static int xk2linux[0x10000] = {
        [XK_plus] = KEY_EQUAL,
 };
 
+static int btnmap[] = {
+       BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_FORWARD, BTN_BACK
+};
+
 static void on_kbd_event(rfbBool down, rfbKeySym keycode, rfbClientPtr cl)
 {
        /*
@@ -184,8 +188,11 @@ static void on_ptr_event(int buttonMask, int x, int y, rfbClientPtr cl)
                down = buttonMask & (1 << i);
                if (down == last_down)
                        continue;
-               /* FIXME this assumes buttons are numbered the same; verify they are */
-               if (xenfb_send_key(xenfb, down != 0, BTN_MOUSE + i) < 0)
+               if (i >= sizeof(btnmap) / sizeof(*btnmap))
+                       break;
+               if (btnmap[i] == 0)
+                       break;
+               if (xenfb_send_key(xenfb, down != 0, btnmap[i]) < 0)
                        fprintf(stderr, "Button %d %s lost (%s)\n",
                                i, down ? "down" : "up", strerror(errno));
        }